using System;
using System.ComponentModel;
using System.ComponentModel.Design;

namespace Camalon.Drawing.Design
{
	/// <summary>
	/// Summary description for ShapePenDesigner.
	/// </summary>
	public class ShapePenDesigner:ShapeDependencyDesigner
	{

		protected readonly PropertyDescriptorCollection PenProperties = TypeDescriptor.GetProperties(typeof(ShapePen));

		public ShapePenDesigner()
		{
			//
			// TODO: Add constructor logic here
			//
		}


		protected override string ShapePropertyName
		{
			get
			{
				return "Pen";
			}
		}

		protected override void Dispose(bool disposing)
		{
			if( base.ChangeService != null)
				base.ChangeService.ComponentRemoved-=new ComponentEventHandler(OnComponentRemoved);
			base.Dispose (disposing);
		}

		protected ShapePen Pen
		{
			get{ return this.Component as ShapePen;}
		}

		public override void Initialize(System.ComponentModel.IComponent component)
		{
			base.Initialize (component);
			
			if( base.ChangeService != null)
				base.ChangeService.ComponentRemoved+=new ComponentEventHandler(OnComponentRemoved);



		}


		private void OnComponentRemoved(object sender, ComponentEventArgs e)
		{
			if( e.Component == null || this.Pen == null) return;

			if( e.Component == this.Pen.Fill)  PenProperties["Fill"].SetValue( this.Pen, null);
			
			
		}


		
	}


}
